package com.lich.controller;


import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

import com.lich.entity.graph.ClientAnalysis;
import com.lich.entity.vo.Result;
import com.lich.service.graph.UserLivenessAnalysisService;

/**
 * @description: 启动次数统计图表
 * @author: yuanyh   
 * @Time: 2016年9月7日
 */
@Controller
@RequestMapping("/user/Liveness")
public class UserLivenessController {

	@Resource
	UserLivenessAnalysisService userLivenessAnalysisService;
	/**
	 * @description:日活跃度
	 * @author: yuanyh 
	 * @Time: 2016年9月7日  
	 * @return
	 */
	@RequestMapping(value="/day", method = RequestMethod.POST)
	public ModelAndView  userDayLivenessMethod(ClientAnalysis clientAnalysis){	 
		Result<ClientAnalysis> result = new Result<>();
		userLivenessAnalysisService.findUserDayLivenessService(clientAnalysis);
		if(clientAnalysis.getDataList().size()>0){
			result.setObject(clientAnalysis);
			result.setSuccess(true);
			result.setMessage("获取数据成功");
		}else{
			result.setSuccess(false);
			result.setMessage("无数据");
		}
		return new ModelAndView(new MappingJackson2JsonView(), "result", result);
	}
	/**
	 * @description:周活跃度
	 * @author: yuanyh 
	 * @Time: 2016年9月7日  
	 * @return
	 */
	@RequestMapping(value="/week", method = RequestMethod.POST)
	public ModelAndView  userWeekLivenessMethod(ClientAnalysis clientAnalysis){	 
		Result<ClientAnalysis> result = new Result<>();
		userLivenessAnalysisService.findUserWeekLivenessService(clientAnalysis);
		if(clientAnalysis.getDataList().size()>0){
			result.setObject(clientAnalysis);
			result.setSuccess(true);
			result.setMessage("获取数据成功");
		}else{
			result.setSuccess(false);
			result.setMessage("无数据");
		}
		return new ModelAndView(new MappingJackson2JsonView(), "result", result);
	}
	/**
	 * @description:月活跃度
	 * @author: yuanyh 
	 * @Time: 2016年9月7日  
	 * @return
	 */
	@RequestMapping(value="/month", method = RequestMethod.POST)
	public ModelAndView  userMonthLivenessMethod(ClientAnalysis clientAnalysis){	 
		Result<ClientAnalysis> result = new Result<>();
		userLivenessAnalysisService.findUserMonthLivenessService(clientAnalysis);
		if(clientAnalysis.getDataList().size()>0){
			result.setObject(clientAnalysis);
			result.setSuccess(true);
			result.setMessage("获取数据成功");
		}else{
			result.setSuccess(false);
			result.setMessage("无数据");
		}
		return new ModelAndView(new MappingJackson2JsonView(), "result", result);
	}
	
}
